package com.wsf.main.common;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

@Data
public class ResultUtil<T> {
    @ApiModelProperty(value = "200为成功")
    private int code;
    @ApiModelProperty(value = "描述")
    private String message;
    private T data;

    /**
     * @Author: 王胜凡
     * @CreateTime: 2022/7/16  16:29
     * @Description: 公共成功类
     * @Version: 1.0
     */
    public static <T>ResultUtil success(T data) {
        ResultUtil resultUtil = new ResultUtil();
        resultUtil.setMessage("操作成功");
        resultUtil.setCode(200);
        resultUtil.setData(data);
        return resultUtil;
    }
    /**
     * @Author: 王胜凡
     * @CreateTime: 2022/7/16  16:29
     * @Description: 公共失败类
     * @Version: 1.0
     */
    public static <T>ResultUtil fail(int code,String message) {
        ResultUtil resultUtil = new ResultUtil();
        resultUtil.setMessage(message);
        resultUtil.setCode(code);
        return resultUtil;
    }
}
